/* * Gui_Start.java * * Created on May 10, 2006 * Latest version: July 20, 2006 * * This class is a part of the Assessment of Comprehension program (AoC), created * for the Language Science Lab at Boston University, under the grant entitled * "Assessment of Comprehension Skills in Older Struggling Readers." Please * direct any questions regarding the project to Gloria S. Waters or David N. * Caplan. * * This program was written by Sam Fentress [add any subsequent authors here]. * Questions about the program may be directed to sfentress@gmail.com. * * This program is released WITHOUT COPYRIGHT into the PUBLIC DOMAIN. This * program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * @author Sam Fentress * @version 0.05 */ package gui; import aoc.*; import javax.swing.JOptionPane; /** * Splash screen depicting program name and version number. * * @author Sam Fentress * @version 0.05 */ public class Gui_Start extends javax.swing.JFrame { AoC aoc; TestValidator validator; /** Creates new form Gui_Start */ public Gui_Start(AoC aoc) { this.aoc = aoc; // setDefaultLookAndFeelDecorated(true); initComponents(); setLocationRelativeTo(null); runButton.grabFocus(); } public void setStatus(String statusMessage, boolean testsAreOk, TestValidator validator){ this.status.setText(statusMessage); this.validator = validator; if (!testsAreOk) validateButton.setEnabled(true); runButton.grabFocus(); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; jLabel1 = new javax.swing.JLabel(); jSeparator1 = new javax.swing.JSeparator(); runButton = new javax.swing.JButton(); practiceButton = new javax.swing.JButton(); jSeparator2 = new javax.swing.JSeparator(); status = new javax.swing.JLabel(); validateButton = new javax.swing.JButton(); getContentPane().setLayout(new java.awt.GridBagLayout()); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Assessment of Comprehension"); setResizable(false); jLabel1.setFont(new java.awt.Font("Lucida Grande", 1, 14)); jLabel1.setText("Assessment of Comprehension v 0.06"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 3; gridBagConstraints.insets = new java.awt.Insets(30, 70, 0, 70); getContentPane().add(jLabel1, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 1; gridBagConstraints.gridwidth = 3; gridBagConstraints.ipadx = 287; gridBagConstraints.ipady = 9; gridBagConstraints.insets = new java.awt.Insets(0, 50, 0, 50); getContentPane().add(jSeparator1, gridBagConstraints); runButton.setFont(new java.awt.Font("Lucida Grande", 1, 13)); runButton.setText("Run"); runButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { runButtonMouseClicked(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 3; gridBagConstraints.gridwidth = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints.insets = new java.awt.Insets(60, 10, 30, 0); getContentPane().add(runButton, gridBagConstraints); practiceButton.setFont(new java.awt.Font("Lucida Grande", 1, 13)); practiceButton.setText("Practice"); practiceButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { practiceButtonActionPerformed(evt); } }); practiceButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { practiceButtonMouseClicked(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 3; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.insets = new java.awt.Insets(60, 122, 30, 21); getContentPane().add(practiceButton, gridBagConstraints); jSeparator2.setForeground(new java.awt.Color(115, 115, 115)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 4; gridBagConstraints.gridwidth = 3; gridBagConstraints.ipadx = 450; gridBagConstraints.ipady = 9; getContentPane().add(jSeparator2, gridBagConstraints); status.setText("checking validation..."); status.setEnabled(false); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 5; gridBagConstraints.gridwidth = 2; gridBagConstraints.insets = new java.awt.Insets(0, 21, 6, 0); getContentPane().add(status, gridBagConstraints); validateButton.setText("Validate"); validateButton.setEnabled(false); validateButton.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { validateButtonMouseClicked(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 5; gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraints.insets = new java.awt.Insets(0, 0, 6, 7); getContentPane().add(validateButton, gridBagConstraints); pack(); }// </editor-fold>//GEN-END:initComponents private void validateButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_validateButtonMouseClicked boolean testsAreOk = validator.validateTests(); status.setText(validator.getStatus()); if (testsAreOk) validateButton.setEnabled(false); else { JOptionPane.showMessageDialog(this, "Warning: The following errors were found:\n\n" + validator.getErrorMessage() + "\nYou should make the necessary corrections before running the tests. \nIf you choose to continue anyway, " + "the test may not run as expected.", "Warning", JOptionPane.WARNING_MESSAGE); } runButton.grabFocus(); System.out.println(validator.getErrorMessage()); validator.clearErrorMessage(); }//GEN-LAST:event_validateButtonMouseClicked private void practiceButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_practiceButtonActionPerformed // TODO add your handling code here: }//GEN-LAST:event_practiceButtonActionPerformed private void practiceButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_practiceButtonMouseClicked aoc.runNewPractice(); }//GEN-LAST:event_practiceButtonMouseClicked private void runButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_runButtonMouseClicked aoc.getStudent(); }//GEN-LAST:event_runButtonMouseClicked /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { // new Gui_Start().setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel jLabel1; private javax.swing.JSeparator jSeparator1; private javax.swing.JSeparator jSeparator2; private javax.swing.JButton practiceButton; private javax.swing.JButton runButton; private javax.swing.JLabel status; private javax.swing.JButton validateButton; // End of variables declaration//GEN-END:variables }